const float kAmbient = 0.2;
const vec4 ambient = vec4(kAmbient, kAmbient, kAmbient, 1.0);

const float kGlobalAmbient = 0.2;
const vec4 globalAmbient = vec4(kGlobalAmbient, kGlobalAmbient, kGlobalAmbient, 1.0);

uniform sampler2D texture;
uniform vec3 lightPos;

varying float kDiffuse;
varying float kFalloff;

void main() {
    vec4 texel = texture2D(texture, gl_TexCoord[0].st);
    
    vec4 lightSum;
    lightSum.r = kFalloff * (ambient.r + kDiffuse);
    lightSum.g = kFalloff * (ambient.g + kDiffuse);
    lightSum.b = kFalloff * (ambient.b + kDiffuse);
    lightSum.a = ambient.a;
    
    vec4 lightColorLim = clamp(globalAmbient + lightSum, 0.0, 1.0);
    
    vec3 finalColor3 = texel.rgb * lightColorLim.rgb;
    float finalAlpha = texel.a   * lightColorLim.a  ;
    
    vec4 finalColor4 = vec4(finalColor3, finalAlpha);
    gl_FragColor = clamp(finalColor4, 0.0, 1.0);
}
